<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //1、数组转换成map
        let array=[["good","好"],["bad","坏"]];
        let map1=new Map(array);
        console.log(map1);

        //2、将map转换成数组
        console.log([...map1]);  //键与值的二维数组
        console.log([...map1.entries()]);//键与值的二维数组
        console.log([...map1.values()]);  //值
        console.log([...map1.keys()]);  //键

        //3、对象转换成Map
        let obj={name:"张果",height:"198"};
        var entries=Object.entries(obj);  //将对象转换成数组
        console.log(entries);
        let map2=new Map(entries);
        console.log(map2);
    </script>
</body>
</html>